package org.yeruyi.common.util;

import android.content.Context;
import android.content.pm.PackageManager;

/**
 * Author: Yeruyi
 * Date: 2018/1/23
 * Version:v1.0
 * Scope:
 * 2018年1月23日 构建工具
 */
public class BuildUtil {

    /**
     * 获取meta值 boolean
     *
     * @param context
     * @param metaName
     * @param defaultValue
     * @return
     */
    public static boolean getAppMetaDataBoolean(Context context, String metaName, boolean defaultValue) {
        try {
            boolean value = context.getPackageManager()
                    .getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA)
                    .metaData.getBoolean(metaName, defaultValue);
            return value;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
            return defaultValue;
        }
    }
    /**
     * 获取meta值 String
     *
     * @param context
     * @param metaName
     * @return
     */
    public static String getAppMetaDataString(Context context, String metaName) {
        try {
            String value = context.getPackageManager()
                    .getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA)
                    .metaData.getString(metaName, "");
            return value;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
            return "";
        }
    }
}
